package main

import (
	"context"
	"github.com/1141520944/go-library/hjz/common"
	pClient "github.com/1141520944/go-library/hjz/proxy/client"
	"github.com/1141520944/go-library/library/log"
	"github.com/gin-gonic/gin"
	"net/http"
)

var l *log.Logger

func main() {
	ctx, cancel := context.WithCancel(context.Background())
	l = common.LoggerDefault("proxy_client.log", "./tqLogger/client")
	if err := pClient.DefaultClient(
		ctx, l,
		pClient.WithWsClientAddr("127.0.0.1:9999/ws/conn"),
		pClient.WithWsClientLocalPort("8000"),
		pClient.WithWsClientLog(l),
	); err != nil {
		l.Errorw("init client err", err.Error())
		return
	}
	l.Info("init client ....")
	common.AddRouter(pClient.Handler())
	e := gin.Default()
	r := common.InitRouter(e, l)
	common.Run(l, &http.Server{Addr: "0.0.0.0:9000", Handler: r}, cancel)
}
